<template>
    <div class="border-style-dashed border-orange gap-100 flex-col-center">
        登录页面
        <div>
            {{ result }}
        </div>
        <button @click="_login(false)">登录</button>
        <button @click="_login(true)">管理员登录</button>
    </div>
</template>

<script setup lang="ts">
import { login } from '@/services/api';
import type { LoginResponse } from '@/services/modules';
import { ref } from 'vue';

const result = ref<LoginResponse>({})
const _login = async (isAdmin: boolean) => {
    const { code, data } = await login({
        username: 'admin',
        password: 'admin'
    })

    if (code === 200) {
        result.value = data
        localStorage.setItem('token', data.token!)
        // 重新加载页面
        window.location.reload()
    }
}

</script>

<style scoped></style>